package com.group3.controller.teacherController;

import com.group3.domain.GroupScores;
import com.group3.domain.PersonalScores;
import com.group3.pojo.Page;
import com.group3.pojo.result.PersonalScoresResult;
import com.group3.service.TeacherScoreService;
import com.group3.utils.Result;
import com.group3.pojo.WorkDetails;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @ClassName TeacherScoreController - 综合打分
 * @Author jt-sinlio,PX
 * @Time 2021/6/5 19:57
 **/
@Api(tags = "教师接口")
@RestController
@RequestMapping("/teacher/score")
public class TeacherScoreController {
    @Resource
    private TeacherScoreService teacherScoreService;
    //-------------------------个人评分-----------------------

    // 查询个人得分列表
    @ApiOperation(value = "查询个人得分列表")
    @GetMapping(value = "/student")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lessonName", value = "项目名称",
                    dataType = "String"),
            @ApiImplicitParam(name = "groupId", value = "小组名称(id)",
                    dataType = "String"),
            @ApiImplicitParam(name = "teacherId", value = "教师id",
                    dataType = "String",required = true)
    })
    public Result<List<PersonalScores>> selectStudentScore(String lessonName,Integer groupId,String teacherId,
                                                           @Validated Page page) {

        return teacherScoreService.selectStudentScore(lessonName,groupId,teacherId,page);
    }

    //查询个人得分详情
    @ApiOperation(value = "查询个人得分详情")
    @GetMapping(value = "/student/resource")
    @ApiImplicitParams({
            //学生成绩与项目名绑定
            @ApiImplicitParam(name = "studentId", value = "学生id",
                    dataType = "String",required = true),
            @ApiImplicitParam(name = "lessonName", value = "项目名称",
                    dataType = "String",required = true)
    })
    public Result<PersonalScoresResult> showStudentScore(String studentId,String lessonName) {

        return teacherScoreService.showStudentScore(studentId,lessonName);
    }

    // 给学生打分
    @ApiOperation(value = "教师给学生打分")
    @PutMapping(value = "/student")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherId", value = "教师id",
                    dataType = "String"),
            @ApiImplicitParam(name = "studentId", value = "学生id",
                    dataType = "String"),
            @ApiImplicitParam(name = "lessonName", value = "项目名称",
                    dataType = "String"),
            @ApiImplicitParam(name = "score", value = "得分",
                    dataType = "float"),
            @ApiImplicitParam(name = "comment", value = "教师评语",
                    dataType = "String")
    })
    public Result gradeStudent(
            @NotBlank @RequestParam String studentId,
            @NotBlank @RequestParam String lessonName,
            @NotBlank @RequestParam float score,
            @RequestParam String comment) {

        return teacherScoreService.gradeStudent(studentId,lessonName,score,comment);
    }


    //-------------------------小组评分-----------------------
    // 查询小组得分列表
    @ApiOperation(value = "查询小组得分列表")
    @GetMapping(value = "/group")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherId", value = "教师id",
                    dataType = "String"),
            @ApiImplicitParam(name = "lessonName", value = "项目名称",
                    dataType = "String"),
            @ApiImplicitParam(name = "groupId", value = "小组id",
                    dataType = "String")
    })
    public Result<List<GroupScores>> selectGroupScore(
            @NotEmpty String lessonName,
            @NotEmpty Integer groupId,
            @NotEmpty String teacherId,
            @Validated Page page) {

        return teacherScoreService.selectGroupScore(lessonName,groupId,teacherId,page);
    }

    //查询小组得分详情
    @ApiOperation(value = "查询小组得分详情")
    @GetMapping(value = "/group/resource")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupId", value = "小组id", dataType = "String"),
            @ApiImplicitParam(name = "lessonName", value = "项目名称", dataType = "String"),
            @ApiImplicitParam(name = "teacherId", value = "教师id", dataType = "String")
    })
    public Result<WorkDetails> showGroupScore(@NotEmpty Integer groupId, @NotEmpty String lessonName) {

        return teacherScoreService.showGroupScore(groupId,lessonName);
    }

    // 给小组打分
    @ApiOperation(value = "教师给小组打分")
    @PutMapping(value = "/group")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupId", value = "小组id", dataType = "String"),
            @ApiImplicitParam(name = "lessonName", value = "项目名称", dataType = "String"),
            @ApiImplicitParam(name = "score", value = "得分", dataType = "float"),
            @ApiImplicitParam(name = "comment", value = "教师评语", dataType = "String"),
            @ApiImplicitParam(name = "teacherId", value = "教师id", dataType = "String")
    })
    public Result groupGroup(
            @NotBlank @RequestParam Integer groupId,
            @NotBlank @RequestParam String lessonName,
            @NotBlank @RequestParam float score,
            @RequestParam String comment) {

        return teacherScoreService.groupGroup(groupId,lessonName,score,comment);

    }
}
